﻿using AutoBogus;
using Microsoft.AspNetCore.Mvc;
using UnitTest.Model;

namespace UnitTestDemo.Controller;

[Route("api/[controller]")]
[ApiController]
public class TestController
{
    public TestController()
    {
    }
    
    public Student _student;
    public TestController(Student student)
    {
        _student = student;
    }
    
    [HttpGet("{id}")]
    public async Task<Student> Get(int id)
    {
        return null;
    }

    [HttpGet]
    public async Task AutoData()
    {
        // 使用AutoBogus库自动生成测试数据
        var faker = new AutoFaker<Student>();
        
        // 生成单个 student 对象
        var stu = faker.Generate();
        Console.WriteLine($"Id：{stu.ID}");
        Console.WriteLine($"Name：{stu.Name}");
        Console.WriteLine($"Age：{stu.Age}");
        Console.WriteLine($"Genger：{stu.Gender}");
        Console.WriteLine($"Status：{stu.Status}");
        
        // 生成多个 Person 对象
        var stus = faker.Generate(5);
        foreach (var a in stus)
        {
            Console.WriteLine($"Id：{a.ID}");
            Console.WriteLine($"Name：{a.Name}");
            Console.WriteLine($"Age：{a.Age}");
            Console.WriteLine($"Genger：{a.Gender}");
            Console.WriteLine($"Status：{a.Status}");
        }
    }

    public int Add(int a,int b)
    {
        return a + b;
    }

}